package cn.dw.mm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.dw.mm.domain.Itorder;
import cn.dw.mm.service.OrderService;

@Controller
@RequestMapping("/itorder")
public class OrderController {

	@Autowired
	private OrderService orderService;
	
	@RequestMapping("/page")
	public String page() {
		return "itorder/list";
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public String add(Itorder order) {
		orderService.insertSelective(order);
		return "{\"static\":\"success\"}";
	}
	@RequestMapping("/mod")
	@ResponseBody
	public String mod(Itorder order) {
		orderService.updateByPrimaryKey(order);
		return "{\"static\":\"success\"}";
	}
	
	
	@RequestMapping("/del")
	@ResponseBody
	public String del(String ids) {
		String[] strIds = ids.split(",");
		for(String id : strIds) {
			orderService.deleteByPrimaryKey(Integer.parseInt(id));
		}
		return "{\"static\":\"success\"}";
	}
	
	@RequestMapping("/query")
	@ResponseBody
	public List<Itorder> query(Itorder oItorder) {
		return  orderService.selectAll(oItorder);
//		return "{\"status\":\"成功\"}";
	}
	
	
}
